package org.mlz.game.model

import org.itheima.kotlin.game.core.Composer
import org.itheima.kotlin.game.core.Painter
import org.mlz.game.Config
import org.mlz.game.business.Attackable
import org.mlz.game.business.Blockable
import org.mlz.game.business.Destroyable
import org.mlz.game.business.Sufferable

/**
 *<p>
 *砖墙
 *
 * 具备阻塞能力
 * 具备挨打能力
 * 具备销毁能能力
 *</p>
 * CreateBy  Malingzhao
 * @date  2020/9/18
 */
class Wall(override val x: Int, override val y: Int) : Blockable, Sufferable, Destroyable {
    /**
     * 判断是否销毁了
     */
    override fun isDestroyed(): Boolean = blood <= 0


    override val width: Int = Config.block

    override val height: Int = Config.block

    /**
     * 生命值
     */
    override var blood: Int = 3

    override fun draw() {
        Painter.drawImage("img/wall.gif", x, y);
    }


    override fun notifySuffer(attackable: Attackable): Array<View>? {
//    println("当前砖墙接收到挨打了.................")
        //子弹打到墙上之后， 子弹需要销毁掉
        //砖墙需要被销毁,砖墙掉血
        blood -= attackable.attackPower

        //喊疼
        Composer.play("snd/hit.wav")
        return arrayOf(Blast(x,y))
    }
//    //位置
//    var x: Int = 100
//    var y: Int = 100
//
//    //宽
//    var width: Int = Config.block
//    //高
//    var height: Int = Config.block
//
//    //显示行为
//    fun draw() {
//        Painter.drawImage("img/wall.gif", x, y);
//    }
}
